package com.ruoyi.zhsu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhsu.domain.Zhsu;
import com.ruoyi.zhsu.service.IZhsuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 住宿费管理Controller
 * 
 * @author tgs
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/system/zhsu")
public class ZhsuController extends BaseController
{
    @Autowired
    private IZhsuService zhsuService;

    /**
     * 查询住宿费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:zhsu:list')")
    @GetMapping("/list")
    public TableDataInfo list(Zhsu zhsu)
    {
        startPage();
        List<Zhsu> list = zhsuService.selectZhsuList(zhsu);
        return getDataTable(list);
    }

    /**
     * 导出住宿费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:zhsu:export')")
    @Log(title = "住宿费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Zhsu zhsu)
    {
        List<Zhsu> list = zhsuService.selectZhsuList(zhsu);
        ExcelUtil<Zhsu> util = new ExcelUtil<Zhsu>(Zhsu.class);
        util.exportExcel(response, list, "住宿费管理数据");
    }

    /**
     * 获取住宿费管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:zhsu:query')")
    @GetMapping(value = "/{学号}")
    public AjaxResult getInfo(@PathVariable("学号") String 学号)
    {
        return success(zhsuService.selectZhsuBy学号(学号));
    }

    /**
     * 新增住宿费管理
     */
    @PreAuthorize("@ss.hasPermi('system:zhsu:add')")
    @Log(title = "住宿费管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Zhsu zhsu)
    {
        return toAjax(zhsuService.insertZhsu(zhsu));
    }

    /**
     * 修改住宿费管理
     */
    @PreAuthorize("@ss.hasPermi('system:zhsu:edit')")
    @Log(title = "住宿费管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Zhsu zhsu)
    {
        return toAjax(zhsuService.updateZhsu(zhsu));
    }

    /**
     * 删除住宿费管理
     */
    @PreAuthorize("@ss.hasPermi('system:zhsu:remove')")
    @Log(title = "住宿费管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{学号s}")
    public AjaxResult remove(@PathVariable String[] 学号s)
    {
        return toAjax(zhsuService.deleteZhsuBy学号s(学号s));
    }
}
